﻿<Window x:Class="StockInfoUI.CorrelationWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Correlation"
        xmlns:mvvm="clr-namespace:StockInfoUI.MVVM">

    <Window.Resources>
        <mvvm:MetricsTable x:Key="MetricsTable"></mvvm:MetricsTable>
        <mvvm:MainTab x:Key="MainTab"></mvvm:MainTab>
        <DataTemplate x:Key="DT_Inside">
            <TabPanel Width="70" Background="DarkOrange" >
                <Border BorderThickness="1,1" BorderBrush="DeepPink" Padding="1">
                    <TextBlock Text="{Binding Path=Value }" Width="70" TextAlignment="Center" Name="TxtCell" Tag="{Binding Path=ValueType}">
                        <TextBlock.Style>
                            <Style TargetType="TextBlock">
                                <Setter Property="Foreground" Value="Black"></Setter>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding ElementName=TxtCell, Path=Tag }" Value="C">
                                        <Setter Property="Foreground" Value="Pink" />
                                        <Setter Property="Background" Value="DimGray" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding ElementName=TxtCell, Path=Tag }" Value="R">
                                        <Setter Property="Foreground" Value="Pink" />
                                        <Setter Property="Background" Value="DimGray" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding ElementName=TxtCell, Path=Tag }" Value="delimeter">
                                        <Setter Property="Foreground" Value="Pink" />
                                        <Setter Property="Background" Value="DimGray" />
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </TextBlock.Style>
                        <!--
                        simple rotation
                        <TextBlock.RenderTransform>
                            <RotateTransform Angle="0" x:Name="txtRotate"></RotateTransform>
                        </TextBlock.RenderTransform>
                        Trigger rotation. need to rotate panel instead of textblock
                                        <Setter Property="RenderTransform">
                                            <Setter.Value>
                                                <RotateTransform Angle="90" />
                                            </Setter.Value>
                                        </Setter>

                        -->
                    </TextBlock>
                </Border>
            </TabPanel>
        </DataTemplate>
        <DataTemplate x:Key="DT_Outside">
            <ItemsControl ItemsSource="{Binding }" ItemTemplate="{DynamicResource DT_Inside}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </ItemsControl>
        </DataTemplate>
    </Window.Resources>

    <TabControl>
        <TabItem Name="tab_ETL" Header="Main">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="1*"></ColumnDefinition>
                    <ColumnDefinition Width="3*"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="8*"></RowDefinition>
                    <RowDefinition Height="1*"></RowDefinition>
                </Grid.RowDefinitions>
                <StackPanel Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" DataContext="{StaticResource MainTab}" >
                    <Label Name="lblButtons" Grid.Row="4" Content="Actions" HorizontalAlignment="Center" ></Label>
                    <Button Width="100" Name="btnCreateDB" Content="Create Database" Command="{Binding CreateDatabase}"></Button>
                    <Button Width="100" Name="btnDropDB" Content="Drop Database" Command="{Binding DropDatabase}"></Button>
                    <Button Width="100" Name="btnLoadData" Content="Load Data" Command="{Binding LoadData}"></Button>
                    <Button Width="100" Name="btnCorrelation" Content="Calc Corellation" 
                            DataContext="{StaticResource MetricsTable}"
                            Command="{Binding CalculateCorrelation}"></Button>
                    <Button Width="100" Name="btnExit" Content="Exit" Command="{Binding CloseCommand}"></Button>
                </StackPanel>
                <StackPanel Grid.Row="0" Grid.Column="1" DataContext="{StaticResource MainTab}">
                    <Label Name="lblSettings" Content="Database / Load Parameters" HorizontalAlignment="Center"></Label>
                    <Label Name="lblConnectionString" Content="{Binding ConnectionString}" ></Label>
                    <Label Name="lblDatabaseName"  Content="{Binding Database}" ></Label>
                    <Label Name="lblDatabaseStatus" Content="{Binding DBStatus}"></Label>
                    <DatePicker Name="dtpFrom" Text="Select From Date" SelectedDate="{Binding DateFrom}" ></DatePicker>
                    <DatePicker Name="dtpTo"  Text="Select To Date" SelectedDate="{Binding DateTo}"></DatePicker>
                </StackPanel>
                
                <ProgressBar Grid.Row="1" Name="PgrBarLoad" Grid.ColumnSpan="2" 
                             DataContext="{StaticResource MainTab}" 
                             Minimum="0" 
                             Maximum="100"
                             Visibility="{Binding LoadVisibility}"
                             Value="{Binding LoadProgress}">
                </ProgressBar>

                <ProgressBar Grid.Row="1" Name="PgrBarCalculate" Grid.ColumnSpan="2" 
                             DataContext="{StaticResource MetricsTable}" 
                             Minimum="0" 
                             Maximum="100"
                             Visibility="{Binding ProgressVisibility}"
                             Value="{Binding CalcProgress}">
                </ProgressBar>


            </Grid>
        </TabItem>
        <TabItem Name="tab_Correlation" Header="Correlation">
            <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" >
                <Grid DataContext="{DynamicResource MetricsTable}"  VerticalAlignment="Top" x:Name="DoubleListTrueRecords" >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="9*"/>
                        <ColumnDefinition Width="7*"/>
                        <ColumnDefinition Width="734*"/>
                    </Grid.ColumnDefinitions>
                    <ItemsControl ItemsSource="{Binding ''}" ItemTemplate="{DynamicResource DT_Outside}" Grid.ColumnSpan="3"/>
                </Grid>
            </ScrollViewer>
        </TabItem>
    </TabControl>
</Window>
